//
//  FeedbackDetailCell.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/26.
//  Copyright © 2016年 Gcx. All rights reserved.
//

#import "FeedbackDetailCell.h"

@implementation FeedbackDetailCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        _unameLabel = [[UILabel alloc]initWithFrame:CGRectMake(ScaleSize(42), ScaleSize(42), 100, 20)];
        _unameLabel.textAlignment = NSTextAlignmentLeft;
        [self.contentView addSubview:_unameLabel];
        
        _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SIZEWIDTH - 200 - ScaleSize(42), ScaleSize(42), 200, 20)];
        _timeLabel.textAlignment = NSTextAlignmentRight;
        [self.contentView addSubview:_timeLabel];
        
        _commentLabel = [[SizeLabel alloc]initWithFrame:CGRectMake(ScaleSize(42), CGRectGetMaxY(_unameLabel.frame)+ScaleSize(48), SIZEWIDTH - ScaleSize(42)*2, 0)];
        _commentLabel.numberOfLines = 0;
        [self.contentView addSubview:_commentLabel];
        
        
        _xian = [[UIView alloc]initWithFrame:CGRectMake(ScaleSize(42), CGRectGetMaxY(_commentLabel.frame)+ScaleSize(42), SIZEWIDTH - ScaleSize(42)*2, 0.5)];
        [self.contentView addSubview:_xian];
        
        [self createUI];

    }
    return self;
}

-(void)createUI{
    
    _xian.backgroundColor = colordbdbdb;
    _commentLabel.font = NormalFont(42);
    _unameLabel.font = NormalFont(42);
    _timeLabel.font = NormalFont(33);
    _commentLabel.textColor = Color333333;
    _timeLabel.textColor = Color999999;
    _unameLabel.textColor = color666666;
    
}

+ (FeedbackDetailCell *)cellWithTab:(UITableView *)tableView{

    static NSString *ident = @"cell";
    
    FeedbackDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:ident];
    
    if (!cell) {
        
        cell = [[FeedbackDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ident];
    }
    return cell;
}


-(void)initWithModel:(FeedbackDetailModel *)mol{
    
    _commentLabel.text = mol.hfnr;
    _unameLabel.text = mol.uname;
    _timeLabel.text = mol.input_time;
    
    
    [_commentLabel sizeToFit];
    
    
    CGFloat height = [_commentLabel labelWithText:mol.hfnr andNum:0];
    
    _commentLabel.frame = CGRectMake(ScaleSize(42), CGRectGetMaxY(_timeLabel.frame)+ScaleSize(48), SIZEWIDTH - ScaleSize(48), height);
    
    _xian.frame = CGRectMake(ScaleSize(42), CGRectGetMaxY(_commentLabel.frame)+ScaleSize(42), SIZEWIDTH - ScaleSize(42), 0);
    
}
@end
